package com.st.mq.annotation_write_way;

import com.st.mq.constant.MqConstant;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author shent
 */
@Component
public class ReceiverHandler {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConstant.FANOUT_QUEUE_D, durable = "true"),
            exchange = @Exchange(
                    value = MqConstant.FANOUT_EXCHANGE,
                    ignoreDeclarationExceptions = "true",
                    type = ExchangeTypes.FANOUT)))
    public void process1(Map msg) {
        System.out.println("通过注解方式监听:Fanout D 消费者收到信息" + msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue(value = MqConstant.TOPIC_QUEUE_OTHER, durable = "true"),
                    exchange = @Exchange(
                            value = MqConstant.TOPIC_EXCHANGE,
                            ignoreDeclarationExceptions = "true",
                            type = ExchangeTypes.TOPIC
                    ),
                    key = {MqConstant.WOMAN}),
            @QueueBinding(
                    value = @Queue(value = MqConstant.FANOUT_QUEUE_A, durable = "true"),
                    exchange = @Exchange(
                            value = MqConstant.FANOUT_EXCHANGE,
                            ignoreDeclarationExceptions = "true",
                            type = ExchangeTypes.FANOUT))})
    public void process2(Map msg) {
        System.out.println("通过注解方式监听:OTHER 消费者收到信息" + msg);
    }
}
